<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:MissedMemo.MeatAndCheeseDisc.OrderMonitor">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="resStyles.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <local:SizeToAbbreviationConverter x:Key="SizeToAbbreviationConverter" />
    
    <DataTemplate DataType="{x:Type local:KitchenOrder}" x:Key="KitchenOrderDataTemplate">

        <Border Name="ItemBorder" Padding="5" Margin="8" Style="{StaticResource DefaultKitchenOrderStyle}" >
            <Grid  Width="120" Height="60">
                
                <Grid.Resources>
                    <!-- TextBlock.VerticalAlignment can't be applied via border style -->
                    <Style TargetType="TextBlock">
                        <Setter Property="TextAlignment" Value="Center" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                    </Style>
                </Grid.Resources>
                
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="1*"/>
                </Grid.ColumnDefinitions>

                <Rectangle Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" RadiusX="8" RadiusY="8"
                           Fill="{StaticResource brushOrderHeaderBackground}" Stroke="{StaticResource brushOrderHeaderOutline}" />
                
                <Button Grid.Row="0" Grid.Column="1" Name="CloseButton" Width="22" Height="22" Content="X"
                        Margin="0,-24,-54,0" Visibility="Hidden" Command="{x:Static local:CustomCommands.CompleteOrderItem}" />

                <TextBlock Grid.Column="0" Grid.Row="0" Text="Order# 123" Foreground="{StaticResource brushOrderNumberText}" />
                <TextBlock Grid.Column="1" Grid.Row="0" Text="00:00" Foreground="{StaticResource brushElapsedTimeText}" />
                
                <TextBlock Grid.Column="0" Grid.Row="2" Text="{Binding Pizza.ItemType}" />
                <TextBlock Grid.Column="1" Grid.Row="2" Foreground="{StaticResource brushPizzaSizeText}"
                           Text="{Binding Pizza.Size, Converter={StaticResource SizeToAbbreviationConverter}}" />
                
            </Grid>
        </Border>
        
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}}" Value="True" >
                <Setter TargetName="ItemBorder" Property="Style" Value="{StaticResource SelectedKitchenOrderStyle}" />
                <Setter TargetName="CloseButton" Property="Visibility" Value="Visible" />
                <Setter TargetName="ItemBorder" Property="Margin" Value="5,18,8,5" />
                <Setter TargetName="ItemBorder" Property="LayoutTransform">
                    <Setter.Value>
                        <ScaleTransform CenterX="0" CenterY="0" ScaleY="1.25" ScaleX="1.25" />
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </DataTemplate.Triggers>
        
    </DataTemplate>
    
</ResourceDictionary>